import logging
from fastapi import APIRouter
from fastapi.exceptions import HTTPException

from app.controllers.storage import storage_config_controller
from app.schemas.base import Success
from app.schemas.storage import StorageConfigCreate

logger = logging.getLogger(__name__)
router = APIRouter()

@router.get("/config", summary="获取存储路径配置")
async def get_storage_config():
    """获取存储路径配置"""
    storage_obj = await storage_config_controller.get_config()
    if not storage_obj:
        return Success(data={
            "image_path": "",
            "video_path": ""
        })
    return Success(data=await storage_obj.to_dict())

@router.post("/config", summary="更新存储路径配置")
async def update_storage_config(storage_config: StorageConfigCreate):
    """更新存储路径配置"""
    await storage_config_controller.create_or_update(storage_config)
    return Success(msg="Updated Successfully") 